package cn.tedu;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

public class Demo04 {
    public static void main(String[] args) {
        try (Connection conn = DBUtils.getConn()){//自动关闭
            Statement statement = conn.createStatement();

            ResultSet resultSet = statement.executeQuery("select name,sal from emp");
            while(resultSet.next()){
//                String name = resultSet.getString("name");
//                double sal = resultSet.getDouble("sal");
                String name = resultSet.getString(1);
                double sal = resultSet.getDouble(2);

                System.out.println(name+":"+sal);
            }

        } catch (SQLException throwables) {
            throwables.printStackTrace();
        }
    }
}
